<!DOCTYPE HTML>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
		<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
		<title>我的评价</title>
		<link rel="stylesheet" type="text/css" href="../../../css/aui.css" />
		<link rel="stylesheet" type="text/css" href="../../../css/app.css" />
		<link rel="stylesheet" type="text/css" href="../../../css/swiper.min.css" />
		<style type="text/css">
			body {
				background-color: #f5f5f5;
			}
			/*商品信息*/

			.goods-info-title:after {
				content: '';
				position: absolute;
				background-color: #72D5EF;
				width: 2px;
				left: 0;
				height: 0.7rem;
				margin-top: 0.1rem;
			}

			.ping-star {
				display: inline-block;
				height: 0.9rem;
				margin-left: 0.3rem;
			}

			.aui-row-padded [class*=aui-col-xs-] {
				padding: 0.25rem;
			}

			.shop-comment {
				position: relative;
				font-size: 0.7rem;
				background-color: #F5F5F5;
				color: #999999;
				margin-top: 0.5rem;
				padding: 0.5rem;
				border-radius: 0.25rem;
			}

			.shop-comment:before {
				content: '';
				position: absolute;
				width: 0;
				height: 0;
				border-left: 9px solid transparent;
				border-right: 9px solid transparent;
				border-bottom: 14px solid #F5F5F5;
				top: -13px;
				left: 15px;
			}

			.nomessage {
				text-align: center;
				margin-top: 3.5rem;
			}

			.nomessage img {
				width: 100%;
				height: 4rem;
				margin-bottom: 1.2rem;
			}
		</style>
	</head>

	<body>
		<div id="app" v-cloak>
			<div class="goods-ping ming-bg-white aui-padded-r-10 aui-padded-l-10" style="padding-left:0.75rem;padding-right:0.75rem">
				<div v-for="vo,index in info" @touchstart="gtouchstart(vo.id)" ontouchmove="gtouchmove()" ontouchend="gtouchend()" class="goods-ping-list aui-border-b" style="padding-bottom: 1rem;">
					<div class="aui-info" style="padding: 1rem 0rem 0.5rem 0rem;">
						<div class="">
							<img class="aui-img-round" style="height: 1.5rem;" :src="vo.avatar" />
							<span class="aui-font-size-13 aui-text-default aui-padded-l-10" style="line-height: 1.5rem;">{{vo.nickname}}</span>
						</div>
						<div class="">
							<!--1星-->
							<img class="ping-star" src="../../../image/icon/icon-star-active.png" />
							<!--2星-->
							<img v-if="vo.star_num<2" class="ping-star" src="../../../image/icon/icon-star.png" />
							<img v-if="vo.star_num>1" class="ping-star" src="../../../image/icon/icon-star-active.png" />
							<!--3星-->
							<img v-if="vo.star_num<3" class="ping-star" src="../../../image/icon/icon-star.png" />
							<img v-if="vo.star_num>2" class="ping-star" src="../../../image/icon/icon-star-active.png" />
							<!--4星-->
							<img v-if="vo.star_num<4" class="ping-star" src="../../../image/icon/icon-star.png" />
							<img v-if="vo.star_num>3" class="ping-star" src="../../../image/icon/icon-star-active.png" />
							<!--5星-->
							<img v-if="vo.star_num<5" class="ping-star" src="../../../image/icon/icon-star.png" />
							<img v-if="vo.star_num>4" class="ping-star" src="../../../image/icon/icon-star-active.png" />
						</div>
					</div>
					<div class="aui-font-size-13 ming-text-hui">
						<span class="aui-padded-r-5">{{vo.create_time}}</span>
						<span class="aui-padded-r-5">{{vo.good_sku}}</span>
						<!--<span class="aui-padded-r-5">38码</span>-->
					</div>
					<div class="aui-font-size-14 aui-text-default" style="padding: 0.5rem 0rem;">
						{{vo.content}}
					</div>
					<div class="aui-row aui-row-padded">
						<div v-for="item,index1 in vo.img" tapmode @click="open_img(index,index1)" class="aui-col-xs-4">
							<img class="aui-img-round-5" :src="item" />
						</div>
					</div>
					<div v-if="vo.remark!=''" class="shop-comment">
						<strong>官方回复：</strong>
						<span>{{vo.remark}}</span>
					</div>
				</div>
			</div>
			<div v-if="info.length<1" class="nomessage">
				<img src="../../../image/bg/bg-nomessage.png" style="width:7.55rem;transform:translateX(-50%);"/>
				<div class="aui-font-size-16 ming-text-hui6">
					暂无评价
				</div>
			</div>
		</div>
	</body>
	<script type="text/javascript" src="../../../script/api.js"></script>
	<script type="text/javascript" src="../../../script/vue.js"></script>
	<script type="text/javascript" src="../../../script/common.js"></script>
	<script type="text/javascript" src="../../../script/aui-dialog.js"></script>
	<script>
		var vm = new Vue({
			el: '#app',
			data: {
				info: [],
				page: 1,
				loadmore: true
			},
			methods: {
				get_list: function() {
					get_data('api/good/myGoodComment', {
						token: $api.getStorage('token'),
						page: vm.page
					}, function(ret) {
						if(ret.status) {
							if(ret.data.length < 20) {
								vm.loadmore = false
							}
							ret.data.forEach(function(el) {
								vm.info.push(el)
							})
						}
					})
				}
			}
		})
		apiready = function() {
			vm.get_list()
						fnInitPullRefresh(function() {
							vm.page = 1;
							vm.info = [];
							vm.loadmore = true;
							vm.get_list()
						})
			fnInitScrollToBottom(function(ret) {
				if(vm.loadmore) {
					vm.page++;
					vm.get_list()
				}
			})
		// 	fnInitPullRefresh(function() {
		// 	vm.get_list();
		// 	api.refreshHeaderLoadDone();
			
		// })

			add_event('pingref', function(ret) {
				vm.page = 1;
				vm.info = [];
				vm.loadmore = true;
				vm.get_list()
			})
		}
		var timeOutEvent = 0;

		function gtouchstart(index) {
			timeOutEvent = setTimeout(function() {
				longPress(index)
			}, 500);
			return false;
		};

		function gtouchend() {
			clearTimeout(timeOutEvent);
			if(timeOutEvent != 0) {
				//这里写要执行的内容（尤如onclick事件）
				//			console.log("你这是点击，不是长按");
			}
			return false;
		};

		function gtouchmove() {
			clearTimeout(timeOutEvent);
			timeOutEvent = 0;
		};

		function longPress(index) {
			timeOutEvent = 0;
			//执行长按要执行的内容，如弹出菜单
			del_msg(index)
		}

		function del_msg(id) {
			var dialog = new auiDialog();
			dialog.alert({
				title: "提示",
				msg: '确定要删除这条评价吗？',
				buttons: ['取消', '确定']
			}, function(ret) {
				if(ret) {
					if(ret.buttonIndex == '2') {
						get_data('api/good/delMyGoodComment', {
							token: $api.getStorage('token'),
							id: id
						}, function(ret) {
							if(ret.status) {
								toast('删除成功')
								vm.page = 1;
								vm.info = [];
								vm.loadmore = true;
								vm.get_list()
							}
						})
					}
				}
			})
		}

		function open_img(index,index1) {
			var imageBrowser = api.require('imageBrowser');
			imageBrowser.openImages({
				imageUrls: vm.info[index].img,
				activeIndex: index1
			});
		}
	</script>

</html>
